<?php

namespace CMS;

Class Kernel
{
	public function __construct() {
		spl_autoload_register(array('CMS\Kernel', 'autoload'));
		set_include_path(get_include_path() . PATH_SEPARATOR . ROOT);
		set_include_path(get_include_path() . PATH_SEPARATOR . ROOT . DS . 'lib');

		ini_set('session.save_handler', 'files');
		ini_set('session.save_path', ROOT . DS . 'tmp');

		session_start();

		Route::init();
	}

	static public function autoload($class) {
		$path = explode('\\', strtolower($class));
		$location = implode($path, DS) . '.php';

		if(Helper::real_path($location))
			include_once($location);
	}
}